module SmsMessage
  
  SMS_URL = "http://smsapi.c123.cn/OpenPlatform/OpenApi"
  ACCOUNT = "1001@501396060001"
  API_KEY = "9EEA9027F265209136C03711CB46284C"
  C_GID   = 52

  # "http://dxhttp.c123.cn/tx/?uid=1001@501075810001&pwd=MD5位32密码&mobile=号码&content=内容"
  def self.send_sms_message(phone,message)
    uri = URI(SMS_URL)
    # params = {uid:ACCOUNT,pwd:Digest::MD5.hexdigest("377354"),encode:"utf-8",mobile:"15828050106",content:message}
    params = {action:"sendOnce",ac:ACCOUNT,authkey:API_KEY,cgid:C_GID,c:message,m:phone}
    uri.query = URI.encode_www_form(params)
    res = Net::HTTP.get_response(uri)
    if res.is_a?(Net::HTTPSuccess)
      res.body
    else
      nil
    end
  end

    

  

end 